<template>
  <div class="big-screen-box-product">
    <el-row class="screen-header" justify="space-evenly" align="middle">
      <el-col :span="6">
        <div class="left-date-box">
          <p class="date-p"> {{ currentTime }}</p>
          <p class="week-p">{{ weekDay }}</p>
        </div>
      </el-col>
      <el-col :span="8">
        <h2 class="screenTitle">{{ screenTitle }}</h2>
        <!-- mqtt 测试 -->
        <!-- <mqtt /> -->
      </el-col>
      <el-col :span="6">
        <div class="right-date-box">
          <el-input class="search-input" v-model="search_value" @keyup.enter.native="getList" clearable @clear="getList"
            style="width: 360px" placeholder="搜索" :suffix-icon="Search" />
        </div>
      </el-col>
    </el-row>

    <div class="screen-right-box">
      <el-row class="screen-right-item-level" :gutter="14" justify="space-evenly">
        <el-col :span="24">
          <div class="product-top-10 screen-border-style">
            <h3 class="screen-title-box">单品销售利润排行榜</h3>
            <el-table class="topTable product-top-table" v-loading="loading" :data="personData">
              <el-table-column label="排名" align="center" min-width="80" type="index" :index="indexMethod" />
              <el-table-column label="品名" align="center" prop="name" />
              <el-table-column label="点击量" align="center" prop="dingdan" />
              <el-table-column label="销量" align="center" prop="num1" />
              <el-table-column label="订单量" align="center" prop="num2" />
              <el-table-column label="成交金额" align="center" prop="num3" />
              <el-table-column label="退款金额" align="center" prop="num2" />
              <el-table-column label="销售利润" align="center" prop="num1" />
            </el-table>
          </div>
          <!-- v-show="total > 0" -->
          <div class=" flex flex-row justify-end">
            <el-pagination class="pagination-box" layout="prev, pager, next" :total="100" />
          </div>


          <!-- <el-pagination
            v-model:current-page="currentPage1"
            :page-size="100"
            :small="small"
            :disabled="disabled"
            :background="background"
            layout="total, prev, pager, next"
            :total="1000"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          /> -->

          <!-- <pagination  :total="total" v-model:page="queryParams.pageNum"
            v-model:limit="queryParams.pageSize" @pagination="getList" /> -->

        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script setup name="User" lang="ts">
import { Search } from '@element-plus/icons-vue'
import { UserVO, UserQuery, UserForm } from '@/api/system/hmUser/types';
import { hmSupplierList, hmSupplierGet, hmSupplierPut } from '@/api/group/supplier/index'

import { SupplierTable } from '@/api/group/supplier/types';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
import { AddressInfoVO, AddressInfoQuery, AddressInfoForm } from '@/api/system/addressInfo/types';
import { validateSpaceAndEmoji } from '@/utils/validate'
import mqtt from "./mqtt.vue";

import { ref, onMounted, onUnmounted } from 'vue';
// 当前日期
const currentTime = ref(new Date().toLocaleTimeString());

const weekDays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];

const updateTime = () => {
  currentTime.value = new Date().toLocaleTimeString();
};

// 今日周几
const weekDay = computed(() => {
  const dayNumber = new Date().getDay();
  return weekDays[dayNumber];
});
updateTime();
const intervalId = setInterval(updateTime, 1000);
onMounted(() => {
  // getList();
})
onUnmounted(() => clearInterval(intervalId));

const screenTitle = ref('惠麦销售数据统计大屏');




const userList = ref<UserVO[]>([]);
const loading = ref(false);

const total = ref(0);
const infoData: UserForm = reactive({})

const search_value = ref('');
const personData = reactive([{
  'id': 1,
  'name': '主播名',
  'dingdan': '5000',
  'num1': 100,
  'num2': 100,
  'num3': 100,

},
{
  'id': 2,
  'name': '主播名',
  'dingdan': '5000',
  'num1': 100,
  'num2': 100,
  'num3': 100,
},
{
  'id': 3,
  'name': '主播名',
  'dingdan': '5000',
  'num1': 100,
  'num2': 100,
  'num3': 100,
},
{
  'id': 4,
  'name': '主播名',
  'dingdan': '5000',
  'num1': 100,
  'num2': 100,
  'num3': 100,
},
{
  'id': 5,
  'name': '主播名',
  'dingdan': '5000',
  'num1': 100,
  'num2': 100,
  'num3': 100,
},
{
  'id': 6,
  'name': '主播名',
  'dingdan': '5000',
  'num1': 100,
  'num2': 100,
  'num3': 100,
},
{
  'id': 7,
  'name': '主播名',
  'dingdan': '5000',
  'num1': 100,
  'num2': 100,
  'num3': 100,
},
{
  'id': 8,
  'name': '主播名',
  'dingdan': '5000',
  'num1': 100,
  'num2': 100,
  'num3': 100,
},
{
  'id': 9,
  'name': '主播名',
  'dingdan': '5000',
  'num1': 100,
  'num2': 100,
  'num3': 100,
}, {
  'id': 10,
  'name': '主播名',
  'dingdan': '5000',
  'num1': 100,
  'num2': 100,
  'num3': 100,
}
])

const initFormData: UserForm = {
  userId: undefined,
  deptId: undefined,
  userName: undefined,
  nickName: undefined,
  userType: undefined,
  email: undefined,
  phonenumber: undefined,
  sex: undefined,
  avatar: undefined,
  password: undefined,
  status: undefined,
  loginIp: undefined,
  loginDate: undefined,
  remark: undefined,
  supplier: undefined,
  contactName: undefined,
  gender: undefined,
  phone: undefined,
  wechat: undefined,
  department: undefined,
  position: undefined,
  counterpart: undefined,
  createdAt: undefined
}
const data = reactive<PageData<UserForm, UserQuery>>({
  form: { ...initFormData },
  queryParams: {
    pageNum: 1,
    pageSize: 10,

  },
  rules: {
    userId: [
      { required: true, message: "用户ID不能为空", trigger: "blur" }, { validator: validateSpaceAndEmoji, }
    ],
    deptId: [
      { required: true, message: "部门ID不能为空", trigger: "blur" }, { validator: validateSpaceAndEmoji, }
    ],
    userName: [
      { required: true, message: "用户账号不能为空", trigger: "blur" }, { validator: validateSpaceAndEmoji, }
    ],
    nickName: [
      { required: true, message: "用户昵称不能为空", trigger: "blur" }, { validator: validateSpaceAndEmoji, }
    ],
    userType: [
      { required: true, message: "用户类型不能为空", trigger: "change" }
    ],
    email: [
      { required: true, message: "用户邮箱不能为空", trigger: "blur" }
    ],
    phonenumber: [
      { required: true, message: "手机号码不能为空", trigger: "blur" }, { pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }
    ],
    sex: [
      { required: true, message: "用户性别不能为空", trigger: "change" }, { validator: validateSpaceAndEmoji, }
    ],
    avatar: [
      { required: true, message: "头像地址不能为空", trigger: "blur" }, { validator: validateSpaceAndEmoji, }
    ],
    password: [
      { required: true, message: "密码不能为空", trigger: "blur" }, { validator: validateSpaceAndEmoji, }
    ],
    status: [
      { required: true, message: "帐号状态不能为空", trigger: "change" }
    ],
    loginIp: [
      { required: true, message: "最后登录IP不能为空", trigger: "blur" }, { validator: validateSpaceAndEmoji, }
    ],
    loginDate: [
      { required: true, message: "最后登录时间不能为空", trigger: "blur" }
    ],
    remark: [
      { required: true, message: "备注不能为空", trigger: "blur" }, { validator: validateSpaceAndEmoji, }
    ],
    supplier: [
      { required: true, message: "供应商名称不能为空", trigger: "blur" }, { validator: validateSpaceAndEmoji, }
    ],
    contactName: [
      { required: true, message: "联系人姓名不能为空", trigger: "blur" }, { validator: validateSpaceAndEmoji, }
    ],
    gender: [
      { required: true, message: "性别不能为空", trigger: "blur" }
    ],
    phone: [
      { required: true, message: "联系电话不能为空", trigger: "blur" }, { pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }
    ],
    wechat: [
      { required: true, message: "微信不能为空", trigger: "blur" }, { validator: validateSpaceAndEmoji, }
    ],
    department: [
      { required: true, message: "部门不能为空", trigger: "blur" }, { validator: validateSpaceAndEmoji, }
    ],
    position: [
      { required: true, message: "职位不能为空", trigger: "blur" }, { validator: validateSpaceAndEmoji, }
    ],
    counterpart: [
      { required: true, message: "对接人不能为空", trigger: "blur" }, { validator: validateSpaceAndEmoji, }
    ],
    createdAt: [
      { required: true, message: "创建时间不能为空", trigger: "blur" }
    ]
  }
});

const { queryParams, form, rules } = toRefs(data);

/** 查询用户信息列表 */
const getList = async () => {
  loading.value = true;
  const res = await hmSupplierList(queryParams.value);
  userList.value = res.rows;
  total.value = res.total;
  Object.assign(infoData, res.rows[0])
  loading.value = false;
}

const indexMethod = (index: number) => {

  return index == 0 ? `TOP.${index + 1}` : `NO.${index + 1}`
}

</script>

<style lang="scss" scoped>
.mb40 {
  margin-bottom: 40px;
}

.mt17 {
  margin-top: 17px;
}

.font-color-yellow {
  color: #FFDF72 !important;
}

.h473 {
  height: 473px !important;
}

.h_auto100 {
  height: calc(100% - 10px) !important;
}

.h_auto473 {
  height: calc(100% - 473px) !important;
}

.big-screen-box-product {
  position: relative;
  background: url("@/assets/images/screen/icon_beijing.png");
  // background: #ccc;
  background-size: cover;
  color: #66FFFF;
  // height: 100%;
  width: 100%;
  padding: 0 7px;
  box-sizing: border-box;
  overflow: hidden;

  :deep(.pagination-box) {
    margin: 30px 0;

    .el-pager {

      li,
      .btn-next,
      .btn-prev,
      .btn-prev {
        margin-right: 15px;
        background: url("@/assets/images/screen/icon_fanye@2x.png");
        background-size: cover;
        color: #66FFFF;
      }
    }
  }

  // 分页
  :deep(.el-pagination button),
  :deep(.el-pagination button.is-disabled),
  :deep(.el-pagination button:disabled) {
    background: url("@/assets/images/screen/icon_fanye@2x.png");
    background-size: cover;
    color: #66FFFF;
    margin-right: 15px;
  }

  :deep(.search-input) {
    .el-input__wrapper {
      background: #07107B;
      border: none;
      border-radius: 0;
      box-shadow: none;

    }

    .el-input__inner {
      color: #66FFFF;

    }

    .el-input__suffix-inner {
      cursor: pointer;
    }

    .el-icon {
      color: #66FFFF;
    }

    input::placeholder {
      color: #66FFFF;
    }

  }

  .product-top-table {
    :deep(.cell) {
      height: 63px;
      line-height: 63px;
      box-sizing: border-box;
      font-weight: 600;
      font-size: 24px;
    }
  }

  .el-table--fit {
    background: none;
  }


  .screen-header {
    height: 130px;
    background: url("@/assets/images/screen/icon_toubu@2x.png");
    background-size: 100% 100%;

    .left-date-box {
      background: url("@/assets/images/screen/icon_riqi@2x.png") 100% no-repeat;
      background-size: 100% 100%;
      height: 78px;
      max-width: 308px;
      margin: 0 auto;
      position: relative;
      top: 24px;

      p {
        margin: 0;
        line-height: 34px;
      }

      .date-p {
        font-size: 16px;
        text-indent: 2em;
      }

      .week-p {
        font-size: 12px;
        text-align: right;
        margin-right: 2em;
      }
    }

    .right-date-box {
      height: 60px;
      max-width: 406px;
      background: url("@/assets/images/screen/icon_zhouqi@2x.png") 100% no-repeat;
      background-size: 100% 100%;
      margin: 0 auto;
      display: flex;
      align-items: center;
      padding-left: 14px;
      font-size: 14px;
      position: relative;
      top: 24px;

      .el-button--primary.is-plain {
        border: 1px solid #66FFFF;
        color: #66FFFF;
        background: none;
      }
    }

    .screenTitle {
      // width: 600px;
      text-align: center;
      height: 40px;
      font-family: AlibabaSansKR, AlibabaSansKR;
      font-weight: bold;
      font-size: 40px;
      color: #FFFFFF;
      line-height: 2px;
      letter-spacing: 3px;
      font-style: normal;
    }


  }

  .screen-title-box {
    background: url("@/assets/images/screen/icon_wenzikuang@2x.png") 100% no-repeat;
    background-size: 100% 100%;
    width: 322px;
    height: 60px;
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    line-height: 60px;
    margin: 0 auto;
    position: relative;
    top: -1px
  }


  .screen-border-style {
    width: 100%;
    border: 2px solid #1D74F1;
    border-radius: 0px 0px 10px 10px;
    position: relative;
    overflow: hidden;
  }

  .screen-border-style::before {
    content: " ";
    width: 6px;
    height: 15px;
    background: #0E5FFF;
    position: absolute;
    left: 0;
    top: 0;
    z-index: 1;
  }

  .screen-border-style::after {
    content: " ";
    width: 6px;
    height: 15px;
    background: #0E5FFF;
    position: absolute;
    right: 0;
    top: 0;
    z-index: 1;

  }

  .screen-right-box {
    // height: calc(100vh - 140px);
    // height: 100vh;

    .screen-right-item-level {
      height: auto;
      overflow: hidden;

      .level-left-box {
        .num-box {
          display: flex;
          justify-content: space-evenly;
          padding: 0 10px;

          div {
            width: 104px;
            height: 108px;
            background: url("@/assets/images/screen/icon_dashuzikuang@2x.png") 100% no-repeat;
            background-size: 100% 100%;
            font-size: 64px;
            color: #66FFFF;
            line-height: 104px;
            font-style: normal;
            text-align: center;
          }
        }

        .live-count-box {
          .live-window-box {
            width: 137px;
            height: 93px;
            background: url("@/assets/images/screen/icon_zhibochangci@2x.png") 100% no-repeat;
            background-size: 100% 100%;
            text-align: center;
            padding-top: 15px;
            box-sizing: border-box;
            margin: 0 auto;

            .nums {
              font-weight: bold;
              font-size: 42px;
              color: #66FFFF;
              line-height: 42px;
              letter-spacing: 2px;
            }

            .unit {
              font-weight: 500;
              font-size: 20px;
              color: #66FFFF;
              line-height: 20px;
            }

            .title {
              font-weight: 400;
              font-size: 16px;
              color: #FFFFFF;
              line-height: 16px;
            }

          }

          .target-box {
            width: 152px;
            height: 152px;
            // background: url("@/assets/images/screen/icon_mubiaowancheng@2x.png") 100% no-repeat;
            // background-size: 100% 100%;
            text-align: center;
            // padding-top: 65px;
            box-sizing: border-box;
            margin: 0 auto;

            .title {
              font-weight: 500;
              font-size: 10px;
              color: #FFFFFF;
              line-height: 10px;
              margin-bottom: 6px;
            }

            .nums {
              font-weight: bold;
              font-size: 18px;
              color: #FFDF72;
              line-height: 18px;
              letter-spacing: 1px;
            }
          }


        }
      }

      .person-top-10 {
        padding-top: 40px;
        position: relative;

        .screen-title-box {
          position: absolute;
          right: 10px;
          margin: 0 !important;
        }

        .person-list>:first-child {
          color: #FFDF72;
        }


        .person-list-item {
          // width: 591px;
          height: 40px;
          background: url("@/assets/images/screen/icon_xiaoshouyejikuang@2x.png") 100% no-repeat;
          background-size: 100% 100%;
          display: flex;
          align-items: center;
          justify-content: space-around;
          padding-left: 30px;
          box-sizing: border-box;
          margin-bottom: 2px;
        }

      }

      .product-top-10 {
        .ring3-box {
          .shuzi {
            font-weight: bold;
            font-size: 24px;
            line-height: 28px;
          }

          img {
            width: 82px;
          }

          .ring3-box-title {
            font-family: PingFangSC, PingFang SC;
            font-weight: 600;
            font-size: 14px;
            color: #FFFFFF;
            line-height: 14px;
          }
        }

        .topTable {
          :deep(.el-table__body tr:hover>td.el-table__cell) {
            background-color: #0152CC !important;
          }

          :deep(.el-table__inner-wrapper::before) {
            background-color: #051371 !important;
          }

          &:deep(.el-table__header) {
            .el-table__cell {
              background-color: #051371 !important;
              // background-color:rgba(14, 95, 255, 0.3)  !important;
              border-color: #051371 !important;
            }

            .cell {
              color: #66FFFF;
              // opacity: 0.3;
            }
          }

          &:deep(.el-table__body) {
            .el-table__row {
              .el-table__cell {
                border-color: #051D83 !important;
              }

              &.el-table__row:first-child .cell {
                color: #FFDF72 !important;

              }

              &.el-table__row:nth-child(odd) {
                background-color: #051D83 !important;

              }

              &.el-table__row:nth-child(even) {
                background-color: #051371 !important;

              }
            }



            .cell {
              color: #66FFFF;
              // opacity: 0.3;
            }
          }
        }

      }
    }







  }

}
</style>
